package cn.lliiooll.ippzonetoolbox.task;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Maps;

import java.util.Map;

public class PTaskBuilder {

    private static final BiMap<String, PTask> tasks = Maps.synchronizedBiMap(HashBiMap.<String, PTask>create());

    public static PTaskBuilder builder() {
        return new PTaskBuilder();
    }

    public static PTask remove(String label) {
        PTask task = find(label);
        tasks.remove(label);
        return task;
    }

    public PTask setLabel(String label) {
        tasks.put(label, new PTask());
        return find(label);
    }

    public static PTask find(String label) {
        return tasks.get(label);
    }
}
